#include "Time.h"

Time::Time()
{
}

Time::Time(int inputMin, int inputHour, int inputDay, int inputMon, int inputYear)
{
	min=inputMin;
	hour=inputHour;
	day = inputDay;
	mon =inputMon;
	year = inputYear;
}

int Time::getMin(){return min;}
int Time::getHour() {return hour;}
int Time::getDay() {return day;}
int Time::getMon() {return mon;}
int Time::getYear() {return year;}

void Time::setMin(int inputMin){min = inputMin;}
void Time::setHour(int inputHour){hour=inputHour;}
void Time::setDay(int inputDay){day = inputDay;}
void Time::setMon(int inputMon){mon = inputMon;}
void Time::setYear(int inputYear){year = inputYear;}

string Time::print()
{
	char buffer[MAX_SIZE];
	sprintf_s(buffer,"%d/%d/%d/%d/%d",year,mon,day,hour,min);
	return buffer;
}

Time & Time::operator= (const Time & t)
{
	min=t.min;
	hour = t.hour;
	day = t.day;
	mon = t.mon;
	year = t.year;
	return *this;
}


bool Time::equal(Time t2)
{
	Time t1 = *this;
	bool result;

	if( t1.getYear() == t1.getYear() && t1.getMon()== t2.getMon() && t1.getDay()==t2.getDay() 
		&& t1.getHour() == t2.getHour() && t1.getMin() == t2.getMin()){
		result = true;
	}
	else {
		result = false;
	}

	return result;

}
bool Time::lessThan(Time t2)
{
	Time t1 = *this;
	bool result;
	bool isEqual=true;

	int Time1[5], Time2[5];
	Time1[0]=t1.getMin();
	Time1[1] =t1.getHour();
	Time1[2] = t1.getDay();
	Time1[3]=t1.getMon();
	Time1[4]=t1.getYear();

	Time2[0] = t2.getMin();
	Time2[1] =t2.getHour();
	Time2[2] = t2.getDay();
	Time2[3] =t2.getMon();
	Time2[4]=t2.getYear();

	int index=4;
	do{
		if(Time1[index]<  Time2[index]){
			result = true;
			isEqual =false;
		}
		else if(Time1[index]>Time2[index]){
			result = false;
			isEqual=false;
		}

		index--;
	}while(isEqual==true && index >=0);


	return result;

}

bool Time::largerThan(Time t2){
	Time t1= *this;
	bool result;
	
	if( t1.lessThan(t2) == false && t1.equal(t2)==false){
		result = true;
	}
	else{
		result =false;
	}
	return result;

}